package com.by.autoconfig;

import com.by.token.TokenTemplate;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * token自动配置类  向容器注入   token工具类 (生成token、验证token )
 */
@AutoConfiguration
@EnableConfigurationProperties({TokenProperties.class})
@ConditionalOnProperty(
        prefix = "token",
        name={"enabled"},
        matchIfMissing = true
)
public class TokenAutoConfiguration {

    /**
     * 向容器注入token工具类
     * @return
     */
    @Bean
    public TokenTemplate tokenTemplate(){
        return new TokenTemplate();
    }
}
